import request from '@/utils/request'

// 获取商品列表
export function pageSupplierGoods(query) {
  return request({
    url: '/goods/supplierGoods/paging',
    method: 'post',
    params: query
  })
}

// 保存
export function saveGoods(data) {
  return request({
    url: '/goods/supplierGoods/save',
    method: 'post',
    data: data
  })
}

// 保存
export function saveStock(data) {
  return request({
    url: '/goods/supplierGoods/saveStock',
    method: 'post',
    data: data
  })
}

// 查询商品详情
export function getSupplierGoodsDetail(supplierGoodsId) {
  return request({
    url: '/goods/supplierGoods/getSupplierGoodsDetail',
    method: 'post',
    params: {
      supplierGoodsId: supplierGoodsId
    }
  })
}

// 删除
export function handleDelete(supplierGoodsId) {
  return request({
    url: '/goods/supplierGoods/delete',
    method: 'post',
    params: {
      supplierGoodsId: supplierGoodsId
    }
  })
}

// 批量提交审核
export function updateBatchAuditType(query) {
  return request({
    url: '/goods/supplierGoods/updateBatchAuditType',
    method: 'post',
    params: query
  })
}

// 撤回审核
export function updateWithdrawAuditType(supplierGoodsId) {
  return request({
    url: '/goods/supplierGoods/updateWithdrawAuditType',
    method: 'post',
    params: {
      supplierGoodsId: supplierGoodsId
    }
  })
}

// 审核 供应商商品(通过)
export function saveAuditSupplierGoods(supplierGoods) {
  return request({
    url: '/goods/supplierGoods/saveAuditSupplierGoods',
    method: 'post',
    params: supplierGoods
  })
}

// 审核 供应商商品(拒绝)
export function saveRefuseSupplierGoods(supplierGoodsId, reject) {
  return request({
    url: '/goods/supplierGoods/saveRefuseSupplierGoods',
    method: 'post',
    params: {
      supplierGoodsId: supplierGoodsId,
      reject: reject
    }
  })
}

// 检查导入淘宝商品是否已完成
export function checkUploadTaoBaoZip(id) {
  return request({
    url: '/goods/supplierGoods/checkUploadTaoBaoZip',
    method: 'get',
    params: {
      id
    }
  })
}

/**
 * 获取企业商品类目
 * @param enterpriseId
 */
export function listGoodsCategory(enterpriseId) {
  if (!enterpriseId) {
    return
  }
  return request({
    url: '/goods/projectGoods/listGoodsCategory',
    method: 'get',
    params: {
      enterpriseId: enterpriseId
    }
  })
}
// 批量设置分类（零售+批发）
export function saveBatchSetGoodsCategory(dataParams) {
  return request({
    url: '/goods/supplierGoods/saveBatchSetGoodsCategory',
    method: 'post',
    data: dataParams
  })
}
// 同步商品
export function doSyncSupplierGoodsByDockingSystem(supplierId, enterpriseId) {
  return request({
    url: '/goods/supplierGoods/doSyncSupplierGoodsByDockingSystem',
    method: 'post',
    params: {
      supplierId: supplierId,
      enterpriseId: enterpriseId
    }
  })
}

